package com.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dao.RoleDAO;
import com.pojo.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
@Service
public class RoleService extends ServiceImpl<RoleDAO, Role> {

    @Autowired
    private RoleDAO roleDAO;

    public List selRole() {
        return roleDAO.selectList(null);
    }

    public int countName(String roleName){
        List<Role> list = roleDAO.selectList(new QueryWrapper<Role>().eq("role_name",roleName));
        return list.size();
    }

    public int countNameID(String roleId,String roleName){
        List<Role> list = roleDAO.selectList(new QueryWrapper<Role>().eq("role_name",roleName).eq("role_id",roleId));
        return list.size();
    }
}
